﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Atributes
{
    class AtributeTest
    {
        static void Main(string[] args)
        {
            Type type = typeof(VersionsInAction);
            var methods = type.GetMethods();
            foreach (var method in methods)
            {
                object[] atributes = method.GetCustomAttributes(false);
                if (atributes.Length != 0 &&( atributes[0] is VersionAttribute))
                {
                    VersionAttribute version = (VersionAttribute)atributes[0];
                    Console.WriteLine("Method name: {0}\nVersion: {1} \nComents: {2}",method.Name, version.VersionName, version.Comment);
                    Console.WriteLine();
                }
                
            }
            //Type type = typeof(VersionsInAction);
            //var methods = type.GetMethods();
            //foreach (var method in methods)
            //{
            //    Type atrType = typeof(VersionAttribute);
            //    var atributes = method.GetCustomAttributes(atrType, false);
            //    foreach (var item in atributes)
            //    {
            //        VersionAttribute version = (VersionAttribute)atributes[0];
            //        Console.WriteLine("Method name: {0}\nVersion: {1} \nComents: {2}", method.Name, version.VersionName, version.Comment);
            //        Console.WriteLine();
            //    }

            //}
            
            
        }
    }
}
